﻿
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.SqlServer;

using Microsoft.EntityFrameworkCore;
using ASP_MVVC.Models;

namespace ASP_MVVC.Data
{
    public class ApplicationDbContext : DbContext
    {
        public ApplicationDbContext()
        {
        }

        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
        {
        }

        public DbSet<Invoices> Invoices { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                // 替换为您的实际连接字符串
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=InvoiceManagementDB;Persist Security Info=True;User ID=sa;Password=sa;TrustServerCertificate=True");
            }
        }
    }
}
